<!--
***申请成功***
-->
<template>
  <div>
    <v-header v-if="!$root.ISAPP">
        <div class="nav-tab2">
            <h3>申请成功</h3>
        </div>
    </v-header>
    <step :step='4'></step>
    <div class="register">
      <div class="content">
        <div class="headimg">
          <img src="/static/img/d_success.png" alt="">
        </div>
        <h3>您已成功申请成为买手</h3>
        <p class="gifts" v-if="isNewUser">送您价值88元的新人礼包 <br> 已经发放到您的账户-卡包中</p>
        <p class="tips">挑选商品分享给好友就能获得相应佣金哦</p>
        <div class="btnBox">
          <a href="javascript:;" @click="goCenter">去挑选商品分享给好友</a>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { isDistribution } from '../../common/api/distribution'
import step from './Step'
import { getUrlParam } from '@/common/util'
export default {
  data() {
    return {
      share: {
        desc: '申请斗牛尖货买手',
        title: '申请尖货买手',
        link: `${window.document.location.protocol}//${window.document.location.host}/distribution/apply`,
        imgUrl: ''
      },
      goOpt: {
        urlExist: true,
        urltype: {
          appUrl: {
            name: 'gotoAppFashionCenter',
            params: {
              url: '/distribution/',
              distributionId: ''
            }
          },
          webUrl: {
            name: '/distribution/',
            params: {}
          }
        }
      },
      isNewUser:false
    }
  },
  components: { step },
  created() {
    if (this.$root.ISAPP) {
      window.document.title = '申请成功'
      let param = getUrlParam('param')
      this.$store.dispatch('setUserInfo', JSON.parse(decodeURIComponent(param)))
    }
    this.isNewUser = window.localStorage.getItem('isNewUser')
    window.localStorage.removeItem('isNewUser')
  },
  methods: {
    // getDistribution(){
    //   isDistribution()
    //   .then(res => {
    //     if (res.distributionid) {
    //       window.localStorage.setItem('distributionId', res.distributionid)
    //       this.goOpt.urltype.appUrl.params.url = res.url
    //       this.goOpt.urltype.appUrl.params.distributionId = res.distributionid || ''
    //       console.log('goOpt.urltype: ', this.goOpt.urltype, res)
    //     }else{
    //       setTimeout(() => {
    //         this.getDistribution()
    //       }, 500);
    //     }
    //   })
    //   .catch(e => {
    //     console.log(e)
    //   })
    // },

    goCenter(){
      isDistribution()
      .then(res => {
        if (res.distributionid) {
          window.localStorage.setItem('distributionId', res.distributionid)
          this.goOpt.urltype.appUrl.params.url = res.url
          this.goOpt.urltype.appUrl.params.distributionId = res.distributionid || ''
          console.log('goOpt.urltype: ', this.goOpt.urltype, res)
          this.gotoPage(this.goOpt.urltype)
        }
      })
      .catch(e => {
        console.log(e)
      })
    },

    gotoPage(item) {
      console.log('click item: ', this.$root.ISAPP, item)
      if (this.$root.ISAPP) {
        this.javascriptBridge(item.appUrl)
      } else {
        this.$router.push(item.webUrl.name)
      }
    },
  }
}
</script>
<style lang='scss' scoped>
  .register{
    padding: 0 5vw;
    .content{
      padding: 10vw 5vw;
      text-align: center;
      .headimg{
        width: 25vw;
        height: 25vw;
        margin: 0 auto;
        img{
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }
      h3{
        font-size: 22px;
        margin-top: 30px;
        font-weight: 500;
        color: #333;
      }
      .gifts{
        margin-top: 4vw;
        color: #666;
      }
      .tips{
        margin-top: 60vw;
        font-size: 14px;
        color: #999;
      }
      .btnBox{
        padding-top: 3vw;
        a{
          display: block;
          width: 100%;
          height: 12vw;
          text-align: center;
          line-height: 12vw;
          background: #333;
          color: #fff;
          border-radius: 4px;
          &.disabled{
            background: #ccc;
          }
        }
      }
    }
  }
</style>



